
from flask_restx import Resource
from webargs.flaskparser import use_args
from webargs import fields
from models import db
from resources.collection import  Collection
from models.records import Record
from schemas.records import RecordSchema
from datetime import datetime
co = Collection(Record,RecordSchema)

args = {'name':fields.Str(),
    'time':fields.Function(deserialize=lambda x: datetime.fromtimestamp(int(x)/1e3)),
    'status':fields.Str()}

class RecordResource(Resource):

    @co.get
    def get(self,id):
        pass

    @use_args(args,location='json')
    @co.put
    def put(self,args,id):
        pass
    
    @co.delete
    def delete(self,id):
        pass

class RecordsResource(Resource): 
    
    @use_args({'page':fields.Int(missing=1),'per_page':fields.Int(missing=20)},location='query')
    @co.multiget 
    def get(self,args):
        pass

    @use_args(args,location='json')
    @co.post
    def post(self,args):
        pass


